import type { RouteMeta, RouteRecordRaw } from 'vue-router'

export function buildMeta(data: RouteMeta = {}): RouteMeta {
  return {
    ...data,
    module: 'CDN',
  }
}
export default {
  path: '/cdn',
  meta: buildMeta(),
  component: () => import('@/components/layout/DefaultLayout.vue'),
  children: [
    {
      path: 'node',
      meta: buildMeta({ title: '节点管理' }),
      children: [
        {
          path: 'node-list',
          name: 'CdnNodeNodeList',
          component: () => import('@/views/cdn/node/node-list'),
          meta: buildMeta({ title: '节点列表' }),
        },
        {
          path: 'node-management/:id/:module?',
          name: 'CdnNodeNodeManagement',
          component: () =>
            import('@/views/cdn/node/node-list/modules/NodeDetail.vue'),
          meta: buildMeta({
            title: '节点管理',
            tabs: [
              { title: '基本配置', key: 'base' },
              { title: '缓存配置', key: 'disk' },
              { title: 'WAF 配置', key: 'waf' },
            ],
          }),
        },

        // {
        //   path: 'cascade',
        //   name: 'CdnNodeCascade',
        //   component: () => import('@/views/cdn/node/cascade'),
        //   meta: buildMeta({ title: '节点级联' }),
        // },

        {
          path: 'group-management',
          name: 'CdnGroupManagement',
          component: () => import('@/views/cdn/node/group-management'),
          meta: {
            title: '分组管理',
            showPageHeader: true,
            showBack: false,
            currentActiveMenu: 'CdnGroupManagement',
          },
        },
        {
          path: 'node-version',
          name: 'CdnNodeNodeVersion',
          component: () => import('@/views/cdn/node/node-version'),
          meta: {
            title: '版本管理',
            showPageHeader: true,
            showBack: false,
            currentActiveMenu: 'CdnNodeNodeVersion',
          },
        },
        {
          path: 'security-configuration/:module?',
          name: 'CdnNodeSecurityConfiguration',
          component: () => import('@/views/cdn/node/security-configuration'),
          meta: buildMeta({
            title: '安全管理',
            tabs: [
              { title: '白名单', key: 'whiteList' },
              { title: '自定义规则', key: 'customRules' },
              { title: '速率限制', key: 'speedLimit' },
            ],
          }),
        },
        {
          path: 'port-config',
          name: 'CdnNodePortConfig',
          component: () => import('@/views/cdn/node/port-config'),
          meta: {
            title: '端口配置',
            showPageHeader: true,
            showBack: false,
            currentActiveMenu: 'CdnNodePortConfig',
          },
        },
        // {
        //   path: 'node-deploy/:id/:name',
        //   name: 'CdnNodeDeploy',
        //   meta: {
        //     title: '调整部署',
        //     parentTitle: '安全配置',
        //     showBack: true,
        //     showPageHeader: true,
        //     parentName: 'SecurityConfig',
        //     currentActiveMenu: 'SecurityConfig',
        //   },
        //   component: () =>
        //     import('@/views/cdn/node/node-deploy'),
        // },

        // {
        //   path: 'region-management',
        //   name: 'CdnRegionManagement',
        //   component: () => import('@/views/cdn/node/region-management'),
        //   meta: {
        //     title: '区域管理',
        //     showPageHeader: true,
        //     showBack: false,
        //     currentActiveMenu: 'CdnRegionManagement',
        //   },
        // },
        {
          path: 'domain-list',
          name: 'CdnResolveDomainList',
          component: () => import('@/views/cdn/resolve/domain-list'),
          meta: {
            title: '域名列表',
            showPageHeader: true,
            showBack: false,
            currentActiveMenu: 'CdnResolveDomainList',
          },
        },
        {
          path: 'security-log/:module?',
          name: 'CdnNodeSecurityLog',
          component: () => import('@/views/cdn/node/security-log'),
          meta: buildMeta({
            title: '安全日志',
            tabs: [
              { title: '安全概览', key: 'security' },
              { title: '日志明细', key: 'log' },
            ],
          }),
        },

        // {
        //   path: 'parse-config',
        //   name: 'CdnParseConfig',
        //   component: () => import('@/views/cdn/node/parse-config'),
        //   meta: {
        //     title: '解析配置',
        //     showPageHeader: true,
        //     showBack: false,
        //     currentActiveMenu: 'CdnParseConfig',
        //   },
        // },
        // {
        //   path: 'cluster-management',
        //   name: 'CdnClusterManagement',
        //   component: () => import('@/views/cdn/node/cluster-management'),
        //   meta: {
        //     title: '集群列表',
        //     showPageHeader: true,
        //     showBack: false,
        //     currentActiveMenu: 'CdnClusterManagement',
        //   },
        // },
      ],
    },
  ],
} satisfies RouteRecordRaw
